package com.lrkj.payfee.controller;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.payfee.domain.PaymentItems;
import com.lrkj.payfee.service.IPaymentItemsService;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.common.core.page.TableDataInfo;

/**
 * 付款项目Controller
 *
 * @author yajun_ren
 * @date 2022-03-21
 */
@RestController
@RequestMapping("/payfee/paymentItems")
@Api(tags = "付款项目")
public class PaymentItemsController extends BaseController
{
    @Autowired
    private IPaymentItemsService paymentItemsService;

    /**
     * 查询付款项目列表
     */
    @ApiOperation(value = "查询付款项目列表", notes = "查询付款项目列表")
    @PreAuthorize("@ss.hasPermi('payfee:paymentItems:list')")
    @GetMapping("/list")
    public TableDataInfo list(PaymentItems paymentItems)
    {
        startPage();
        this.changeParameter(paymentItems.getParams());
        List<PaymentItems> list = paymentItemsService.selectPaymentItemsList(paymentItems);
        return getDataTable(list);
    }

    /**
     * 导出付款项目列表
     */
	@ApiOperation(value = "导出付款项目列表", notes = "导出付款项目列表")
    @PreAuthorize("@ss.hasPermi('payfee:paymentItems:export')")
    @Log(title = "付款项目", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PaymentItems paymentItems)
    {
        List<PaymentItems> list = paymentItemsService.selectPaymentItemsList(paymentItems);
        ExcelUtil<PaymentItems> util = new ExcelUtil<PaymentItems>(PaymentItems.class);
        return util.exportExcel(list, "付款项目数据");
    }

    /**
     * 获取付款项目详细信息
     */
	@ApiOperation(value = "获取付款项目详细信息", notes = "获取付款项目详细信息")
    @PreAuthorize("@ss.hasPermi('payfee:paymentItems:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(paymentItemsService.selectPaymentItemsById(id));
    }

    /**
     * 新增付款项目
     */
    @ApiOperation(value = "新增付款项目", notes = "新增付款项目")
    @PreAuthorize("@ss.hasPermi('payfee:paymentItems:add')")
    @Log(title = "付款项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PaymentItems paymentItems)
    {
        return toAjax(paymentItemsService.insertPaymentItems(paymentItems));
    }

    /**
     * 修改付款项目
     */
    @ApiOperation(value = "修改付款项目", notes = "修改付款项目")
    @PreAuthorize("@ss.hasPermi('payfee:paymentItems:edit')")
    @Log(title = "付款项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PaymentItems paymentItems)
    {
        return toAjax(paymentItemsService.updatePaymentItems(paymentItems));
    }

    /**
     * 删除付款项目
     */
    @ApiOperation(value = "删除付款项目", notes = "删除付款项目")
    @PreAuthorize("@ss.hasPermi('payfee:paymentItems:remove')")
    @Log(title = "付款项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(paymentItemsService.deletePaymentItemsByIds(ids));
    }
}
